import url from './../../api/Constance'

<template>
    <div class="kanban">

        <div>
            <el-form :model="admin" :rules="rules" label-width="120px" ref="prize">
                <el-form-item label="管理员密码" prop="password">
                    <el-input style="width: 360px" type="password" v-model="admin.password"></el-input>
                </el-form-item>
                <el-button @click="changePwd" type="primary">确 定</el-button>
            </el-form>
        </div>

    </div>
</template>


<script>
    export default {
        name: 'Admin',
        info: {},
        data() {
            return {
                rules: {
                    password: [
                        {required: true, message: '请输入密码', trigger: 'blur'}
                    ]
                },
                admin: {
                    "password": ''
                }
            }
        },
        methods: {
            changePwd() {
                if (!this.admin.password) {
                    return
                }
                this.$post('/admin/changePassword', this.admin)
                    .then(response => {
                        if (response.code === 0) {
                            this.$message({
                                message: '操作成功！',
                                type: 'success'
                            });
                            setTimeout(() => {
                                    this.$ls.remove("userInfo");
                                    // 跳转到首页
                                    this.$router.push({path: '/'});
                                },
                                1000)

                        } else {
                            this.$message.error(response.msg);
                            return;
                        }
                        this.admin.password = '';
                    });
            },
            mounted() {
            }
        }
    }
</script>

<style>
    .block {
        display: -webkit-flex;
        display: flex;
        justify-content: flex-end;
        padding: 15px 30px;
    }

    .kanban {
        padding: 25px 25px;
    }
</style>
